home *** CD-ROM | disk | FTP | other *** search
Wingz Spreadsheet | 1989-03-17 | 10.2 KB | 158 lines | [WZSS/WNGZ] |
- WNGZWZSS01b1
- Geneva
- Geneva
- Start Game
- Start Game
- put -1 into r1c1..r10c10
- put 0 into r2c2..r9c9
- put 1 into r5c5
- put 1 into r6c6
- put 2 into r5c6
- put 2 into r6c5
- repaint object 1
- Chicago
- Chicago
- New Button
- New Button
- Not a valid move
- Computer has no move
- therow
- thecol
- paintone
- whosnext
- moverank0
- setone
- computermoveZ
- valid
- define therow, thecol, paintone, whosnext
- on repaint
- define x,y,r,c
- fill bg green()
- if paintone
- line width 20
- case index(r2c2..r9c9, thecol, therow)
- when 0
- fill pattern 2
- fill fg white()
- fill rectangle (thecol * 0.125 + 0.015, therow * 0.125 + 0.015) +(0.095, 0.095)
- when 1
- fill bg white()
- paint oval (thecol * 0.125 + 0.015, therow * 0.125 + 0.015) +(0.095, 0.095)
- frame oval (thecol * 0.125 + 0.015, therow * 0.125 + 0.015) +(0.095, 0.095)
- when 2
- fill bg black()
- paint oval (thecol * 0.125 + 0.015, therow * 0.125 + 0.015) +(0.095, 0.095)
- end case
- exit repaint
- end if
- fill pattern 2
- fill fg white()
- paint rectangle (0,0) (1,1)
- fill pattern 20
- fill fg black()
- for x = 0.125 to 0.875 step 0.125
- move (x, 0)
- draw (x, 1)
- move (0, x)
- draw (1, x)
- end for
- line width 20
- for r = 0 to 7
- for c = 0 to 7
- case index(r2c2..r9c9, c, r)
- when 1
- fill bg white()
- paint oval (c * 0.125 + 0.015, r * 0.125 + 0.015) +(0.095, 0.095)
- frame oval (c * 0.125 + 0.015, r * 0.125 + 0.015) +(0.095, 0.095)
- when 2
- fill bg black()
- paint oval (c * 0.125 + 0.015, r * 0.125 + 0.015) +(0.095, 0.095)
- end case
- end for
- end for
- end repaint
- on mouseup
- define xpos,ypos
- xpos = int(mousex() / controlwidth() * 8)
- ypos = int(8 - mousey() / controlheight() * 8)
- if not whosnext
- whosnext = 1
- end if
- if moverank(xpos, ypos, whosnext, TRUE())
- call setone(xpos, ypos, whosnext)
- whosnext = if(whosnext=1,2,1)
- call computermove()
- else
- message "Not a valid move"
- end if
- end mouseup
- function setone(col, row, value)
- put value into makecell(col + 2, row + 2)
- paintone = TRUE()
- therow = row
- thecol = col
- repaint object 1
- paintone = FALSE()
- end function
- function valid(col, row, coloff, rowoff, who, doit)
- define tmp, count, ret, savecol, saverow
- if not index(r2c2..r9c9, col, row)
- tmp = index(r2c2..r9c9, col + coloff, row + rowoff)
- if tmp > 0 and tmp <> who
- count = 1
- savecol = col
- saverow = row
- col = col + coloff
- row = row + rowoff
- while tmp = index(r2c2..r9c9, col + coloff, row + rowoff)
- count = count + 1
- col = col + coloff
- row = row + rowoff
- end while
- if who = index(r2c2..r9c9, col + coloff, row + rowoff)
- ret = count + index(m2..t9, savecol, saverow) + rand()
- if doit
- while savecol <> col or saverow <> row
- call setone(col, row, who)
- col = col - coloff
- row = row - rowoff
- end while
- end if
- end if
- end if
- end if
- return ret
- end function
- function moverank(col, row, who, doit)
- return valid(col, row, -1, -1, who, doit) +
- valid(col, row, -1, 0, who, doit) +
- valid(col, row, -1, 1, who, doit) +
- valid(col, row, 0, -1, who, doit) +
- valid(col, row, 0, 1, who, doit) +
- valid(col, row, 1, -1, who, doit) +
- valid(col, row, 1, 0, who, doit) +
- valid(col, row, 1, 1, who, doit)
- end function
- function computermove()
- define r, c, foundr, foundc, high, tmp
- for r = 0 to 7
- for c = 0 to 7
- tmp = moverank(c, r, whosnext, FALSE())
- if tmp > high
- high = tmp
- foundr = r
- foundc = c
- end if
- end for
- end for
- if high
- call moverank(foundc, foundr, whosnext, TRUE())
- call setone(foundc, foundr, whosnext)
- else
- message "Computer has no move"
- end if
- whosnext = if(whosnext=1,2,1)
- end function
- Chicago
- Chicago
-